package com.juyu.miliao.api.dao.mysql;

import com.juyu.miliao.api.domain.WhitePacketDynamicLikeInfo;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

/**
 * @author xuanqicheng
 * @create 2019-21-16:35
 */
@Repository
public class WhitePacketDynamicLikeInfoDao {
    @Autowired
    private SqlSession sqlSession;
    public int selectDynamicLike(WhitePacketDynamicLikeInfo obj) {
        return sqlSession.selectOne("selectWhitePacketDynamicLike",obj);
    }

    public void deleteDynamicLikeInfo(WhitePacketDynamicLikeInfo obj) {
        sqlSession.delete("deleteWhitePacketDynamicLikeInfo",obj);
    }

    public void addDynamicLikeInfo(WhitePacketDynamicLikeInfo obj) {
        sqlSession.insert("addWhitePacketDynamicLikeInfo",obj);
    }

    public int selectDynamicLikeCount(Long dynamicId) {
       return  sqlSession.selectOne("selectWhitePacketDynamicLikeCount",dynamicId);
    }

    public WhitePacketDynamicLikeInfo selectDynamicLikeByDynamicAndUserId(long userId, long dynamicId) {
        Map<String,Object> map = new HashMap<>();
        map.put("userId",userId);
        map.put("dynamicId",dynamicId);
        return sqlSession.selectOne("selectWhitePacketDynamicLikeByDynamicAndUserId",map);
    }

}
